package com.wn.procurement.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wn.common.PageBean;
import com.wn.entity.Supplier;
import com.wn.procurement.mapper.SupplierMapper;
import com.wn.procurement.service.SupplierService;
import com.wn.procurement.vo.SupplierVo;
import com.wn.utils.PageBeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupplierServiceimpl implements SupplierService {

    @Autowired
    private SupplierMapper supplierMapper;

    @Override
    public void insert(Supplier supplier) {
        supplierMapper.insert(supplier);
    }

    @Override
    public void update(Supplier supplier) {
        supplierMapper.update(supplier);
    }

//    @Override
//    public PageBean<Supplier> getAll() {
//        return null;
//    }

    @Override
    public PageBean<Supplier> getByCondition(SupplierVo supplierVo) {
        Page<Supplier> page = PageHelper.startPage(supplierVo.getCurrPage(), supplierVo.getPageSize());
        List<Supplier> list = supplierMapper.getByCondition(supplierVo.getSupplier());
        return PageBeanUtil.getPageBean(list, page, supplierVo.getCurrPage(), supplierVo.getPageSize());
    }
}
